<template>
  <views class="password_amend">
    <div class="character_name flex flexR">
      <div class="character_name_title ">原密码:</div>
      <div class="character_name_input">
        <el-input v-model="old_password" placeholder="请输入原密码" :clearable="true"></el-input>
      </div>
    </div>
    <div class="character_name flex flexR">
      <div class="character_name_title ">新密码:</div>
      <div class="character_name_input">
        <el-input v-model="new_password" placeholder="请输入新密码" :clearable="true"></el-input>
      </div>
    </div>
    <div class="character_name flex flexR">
      <div class="character_name_title ">重复密码:</div>
      <div class="character_name_input">
        <el-input v-model="new_password1" placeholder="请输入密码" :clearable="true"></el-input>
      </div>
    </div>
    <div class="btn_list flex flexR">
      <el-button type="primary" @click="submit">提交</el-button>
      <el-button type="warning" @click="reset">重置</el-button>
      <!-- <el-button type @click="get_back">返回</el-button> -->
    </div>
  </views>
</template>

<script>
export default {
  data() {
    return {
      old_password: "", // 原密码
      new_password: "", // 新密码
      new_password1: "" // 重复密码
    };
  },
  computed: {
    //实时计算要传输的编辑参数
    post_data() {
      let data = {};
      data.old_password = this.old_password;
      data.new_password = this.new_password;
      return data;
    }
  },
  methods: {
    // 返回
    // get_back() {
    //   this.$blackRoute({ path: '/',query:{},that:this}); 
    // },
    // 重置
    reset() {
      this.original_password = ""; // 原密码
      this.new_password = ""; // 新密码
      this.new_password1 = ""; // 重复密码
    },
    // 提交
    submit() {
      //   服务商
      if (this.$store.state.terrace == 3) {
        let data = this.$api.sendSync(
          this.$mapapi.f_modifyPassword,
          this.post_data
        );
        if (data.code != 200) {
          this.$message.error(data.msg);
          return;
        }
        this.$message.success(data.msg);
        this.$toRoutePath({
          path: "/success",
          edit: true,
          query: {}
        });
      }
      //   代理商
      if (this.$store.state.terrace == 2) {
        let data = this.$api.sendSync(this.$mapapi.f_setpwd, this.post_data);
        if (data.code != 200) {
          this.$message.error(data.msg);
          return;
        }
        this.$message.success(data.msg);
        this.$toRoutePath({
          path: "/success",
          edit: true,
          query: {}
        });
      }
    }
  },
  created() {},
  mounted() {
    this.$setRouteTitle();
  }
};
</script>


<style lang="less" :scope="true">
.password_amend {
  padding: 10px 10px 20px 10px;
  background: #ffffff;
  .btn_list {
    margin-top: 25px;
    margin-left: 55px;
    width: 250px;
    justify-content: space-around;
  }
  .character_name {
    height: 55px;
    -moz-box-align: center;
    -webkit-box-align: center;
    // -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
    -moz-box-pack: center;
    -webkit-box-pack: center;
    // -ms-flex-pack: center;
    width: 550px;
    .character_name_input {
      margin-left: 15px;
      width: 100%;
    }
    .character_name_title {
      width: 130px;
      text-align: left;
    }
    .character_name_title:before {
      content: "*";
      color: red;
    }
  }
}
</style>